<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    //异步函数    返回值是一个 promise 对象
    async function main(){
      //1. 返回是一个非 promise 的数据
      return 123;
      //2. 返回是一个 promise 数据   p.then(resolve, reject);
      // return new Promise((resolve, reject) => {
      //   resolve('OK');
      // });
      //3. 抛出错误
      // throw '出错la~~';
    }

    //箭头函数
    let p = async () => {
      return 'love';
    }

    //匿名函数赋值
    let p2 = async function(){
      throw 'error';
    }

    //IIFE
    (async function(){
      
    })()

    // p().then(v => {
    //   console.log(v);
    // })
    
    p2().catch(r => {
      console.log(r);
    })

  </script>
</body>
</html>